package juc;

import java.util.concurrent.*;

public class MyTheadPoolDemo {
	public static void main(String args[]){
		ExecutorService executorService = new ThreadPoolExecutor(2, 5, 3, TimeUnit.SECONDS,new LinkedBlockingQueue<>(5), Executors.defaultThreadFactory(), new ThreadPoolExecutor.DiscardOldestPolicy());
		System.out.println(Runtime.getRuntime().availableProcessors());
		try {
			for (int i = 0; i < 18; i++) {
				int finalI = i;
				executorService.execute(() -> {
					System.out.println(Thread.currentThread().getName() + "=======" + finalI);
				});
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			executorService.shutdown();
		}
	}
}
